package com.accp.crm.service;

import java.util.List;

import org.hibernate.SessionFactory;

import com.accp.crm.dao.CommonDAO;
import com.accp.crm.entity.Orders;
import com.accp.crm.entity.OrdersLine;
import com.accp.crm.entity.Storage;

public class StorageService implements IStorageService {
    private CommonDAO<Storage> storageDAO;
    
    public  void setSessionFactory(SessionFactory sessionFactory){
    	storageDAO=new CommonDAO<Storage>(sessionFactory, Storage.class);
    }
    
    /* (non-Javadoc)
	 * @see com.accp.crm.service.IStorageService#findByHql()
	 */
    public List findByHql(){
    	String hql="from Storage";
    	return this.storageDAO.findByHQL(hql);
    }

	@Override
	public List findById(Orders order) {
		String hql="from OrdersLine o where o.orders.odrId=?";
	    List list=this.storageDAO.findByHQL(hql, order.getOdrId());
		return list;
	}
}
